import request from '@/request/http'
const userAPI = Object.freeze({
  signUpRequest: '/index/reg',
  signInRequest: '/index/login',
  getUserInfo: '/user/getUserInfo',
  getUserArticle: '/user/myArticle',
  getUserSaveSupport: '/user/userDataList',
  editUserInfo: '/user/update',
  uploadUserAvator: '/common/upload?type=images'
})
const GET = 'GET'
const POST = 'POST'
export const signUpRequest = function (params) {
  return request({
    method: POST,
    url: userAPI.signUpRequest,
    data: params
  })
}
export const signInRequest = function (params) {
  return request({
    method: POST,
    url: userAPI.signInRequest,
    data: params
  })
}
export const getUserInfo = function () {
  return request({
    method: GET,
    url: userAPI.getUserInfo
  })
}
export const getUserArticle = function (page) {
  return request({
    method: GET,
    url: userAPI.getUserArticle,
    params: {
      limit: 10,
      page
    }
  })
}
export const getUserSaveSupport = function (type, page) {
  return request({
    method: GET,
    url: userAPI.getUserSaveSupport,
    params: {
      type,
      page,
      limit: 6
    }
  })
}
export const editUserInfo = function (data) {
  return request({
    method: POST,
    url: userAPI.editUserInfo,
    data
  })
}
export const uploadUserAvator = function (formdata) {
  return request({
    method: POST,
    url: userAPI.uploadUserAvator,
    data: formdata
  })
}
